define(['jtopo','Json2xml'],function (jtopo,Json2xml){

	var customContainer = function (jsonObj){
		this.initialize = function (){
			jsonObj._text && customContainer.prototype.initialize.apply(this, arguments);
		}
		this.initialize();
		this.deserialize(jsonObj);
	}
	customContainer.prototype = new JTopo.Container();

	customContainer.prototype.serialize = function (){
		var _self = this;
		var jsonObj = {
			squareBox : {
				_id : _self.id,
				_x : _self.x,
				_y : _self.y,
				_width : _self.width,
				_height : _self.height,
				_borderColor : _self.borderColor,
				_backgroundColor : _self.fillColor
			}
		};
		var json2xml2 = new Json2xml();
		var resultXml_str = json2xml2.json2xml_str(jsonObj);
		return resultXml_str;
	}
	customContainer.prototype.deserialize = function (jsonObj){
		// this.x = Number(jsonObj._x);
		// this.y = Number(jsonObj._y);
		// this.width = jsonObj._width?Number(jsonObj._width):40;
		// this.height = jsonObj._height?Number(jsonObj._height):40;
		this.id = jsonObj._id;
		jsonObj._borderColor && jsonObj._borderColor.split(',').length==3 && (this.borderColor = jsonObj._borderColor);
		jsonObj._backgroundColor && jsonObj._backgroundColor.split(',').length==3 && (this.fillColor = jsonObj._backgroundColor);
		this.setLocation(Number(jsonObj._x),Number(jsonObj._y));
		this.setSize(jsonObj._width?Number(jsonObj._width):40,jsonObj._height?Number(jsonObj._height):40);
		this.layout = null;
	}

	return customContainer;
	
});
